<%@ page contentType="text/html; charset=utf-8" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<c:set var="basePath" value="${pageContext.request.contextPath}"/>
<!DOCTYPE HTML>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Jsinfo OA</title>

    <link href="${basePath}/resources/zheng-admin/plugins/bootstrap-3.3.0/css/bootstrap.min.css" rel="stylesheet"/>
    <link href="${basePath}/resources/zheng-admin/plugins/material-design-iconic-font-2.2.0/css/material-design-iconic-font.min.css"
          rel="stylesheet"/>
    <link href="${basePath}/resources/zheng-admin/plugins/waves-0.7.5/waves.min.css" rel="stylesheet"/>
    <link href="${basePath}/resources/zheng-admin/plugins/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.min.css"
          rel="stylesheet"/>
    <link href="${basePath}/resources/zheng-admin/css/admin.css" rel="stylesheet"/>
    <style>
        /** skins **/
        <c:forEach var="upmsSystem" items="${upmsSystems}">
        #${upmsSystem.name} #header {background: ${upmsSystem.theme};}
        #${upmsSystem.name} .content_tab{background: ${upmsSystem.theme};}
        #${upmsSystem.name} .s-profile>a{background: url(${basePath}${upmsSystem.banner}) left top no-repeat;}
        </c:forEach>
    </style>
</head>
<body>
<header id="header">
    <ul id="menu">
        <li id="guide" class="line-trigger">
            <div class="line-wrap">
                <div class="line top"></div>
                <div class="line center"></div>
                <div class="line bottom"></div>
            </div>
        </li>
        <li id="logo" class="hidden-xs">
            <a href="${basePath}/manage/index">
                <img src="${basePath}/resources/zheng-admin/images/logo.png"/>
            </a>
            <span id="system_title">权限管理</span>
        </li>
        <li id="system">
            <ul id="nav-menu">

            </ul>
        </li>
        <li class="pull-right">
            <ul class="hi-menu">
                <li class="dropdown">
                    <a class="waves-effect waves-light" data-toggle="dropdown" href="javascript:;">
                        <i class="him-icon zmdi zmdi-notifications"></i>
                    </a>
                    <ul class="dropdown-menu dm-icon pull-right message-box">
                        <li class="hidden-xs">
                            <span class="message-title-left">新消息通知</span>
                            <a class="message-title-right">查看更多...</a>
                        </li>
                        <li class="divider"></li>
                        <li>
                            <a class="waves-effect" data-ma-action="clear-localstorage" href="javascript:;"><i
                                    class="zmdi zmdi-delete"></i> Lorem ipsum dolor sit amet...</a>
                        </li>
                        <li>
                            <a class="waves-effect" href="javascript:;"><i class="zmdi zmdi-face"></i> 隐私管理</a>
                        </li>
                        <li>
                            <a class="waves-effect" href="javascript:;"><i class="zmdi zmdi-settings"></i> 系统设置</a>
                        </li>
                        <li>
                            <a class="waves-effect" href="javascript:;"><i class="zmdi zmdi-run"></i> 退出登录</a>
                        </li>
                    </ul>
                </li>
                <li class="dropdown">
                    <a class="waves-effect waves-light" data-toggle="dropdown" href="javascript:;">
                        <i class="him-icon zmdi zmdi-more-vert"></i>
                    </a>
                    <ul class="dropdown-menu dm-icon pull-right">
                        <li class="hidden-xs">
                            <a class="waves-effect" data-ma-action="fullscreen" href="javascript:fullPage();"><i
                                    class="zmdi zmdi-fullscreen"></i> 全屏模式</a>
                        </li>
                        <li>
                            <a class="waves-effect" data-ma-action="clear-localstorage" href="javascript:;"><i
                                    class="zmdi zmdi-delete"></i> 清除缓存</a>
                        </li>
                        <li>
                            <a class="waves-effect" href="javascript:;"><i class="zmdi zmdi-face"></i> 隐私管理</a>
                        </li>
                        <li>
                            <a class="waves-effect" href="javascript:;"><i class="zmdi zmdi-settings"></i> 系统设置</a>
                        </li>
                        <li>
                            <a class="waves-effect" href="${basePath}/sso/logout"><i class="zmdi zmdi-run"></i> 退出登录</a>
                        </li>
                    </ul>
                </li>
            </ul>
        </li>
    </ul>
</header>
<section id="main">
    <!-- 左侧导航区 -->
    <aside id="sidebar" class="sidebar">
        <!-- 个人资料区 -->
        <div class="s-profile">
            <a class="waves-effect waves-light" href="javascript:;">
                <div class="sp-pic">
                    <img src="${basePath}${upmsUser.avatar}"/>
                </div>
                <div class="sp-info">
                    ${upmsUser.realname}，您好！
                    <i class="zmdi zmdi-caret-down"></i>
                </div>
            </a>
            <ul class="main-menu">
                <li>
                    <a class="waves-effect"
                       href="javascript:Tab.addTab('个人资料','${ZHENG_OA_DOMAIN}/oa/hr/personalRecords/userInfo');"><i
                            class="zmdi zmdi-account"></i> 个人资料</a>
                </li>
                <li>
                    <a class="waves-effect" href="javascript:;"><i class="zmdi zmdi-face"></i> 隐私管理</a>
                </li>
                <li>
                    <a class="waves-effect" href="javascript:;"><i class="zmdi zmdi-settings"></i> 系统设置</a>
                </li>
                <li>
                    <a class="waves-effect" href="${basePath}/sso/logout"><i class="zmdi zmdi-run"></i> 退出登录</a>
                </li>
            </ul>
        </div>
        <!-- /个人资料区 -->
        <!-- 菜单区 -->
        <ul class="main-menu">
            <li>
                <a class="waves-effect" href="javascript:Tab.addTab('首页', 'home');"><i class="zmdi zmdi-home"></i>
                    首页</a>
            </li>
            <c:forEach var="upmsPermission" items="${upmsPermissions}" varStatus="status">
                <c:forEach var="upmsSystem" items="${upmsSystems}">
                    <c:if test="${upmsPermission.systemId == upmsSystem.systemId}">
                        <c:set var="systemBasePath" value="${upmsSystem.basepath}"/>
                    </c:if>
                </c:forEach>
                <c:if test="${upmsPermission.pid == 0}">
                    <li class="<c:if test="${fn:length(upmsPermission.uri)<1}">sub-menu</c:if> system_menus system_${upmsPermission.systemId} ${status.index}"
                        <c:if test="${upmsPermission.systemId != 1}">style="display:none;"</c:if>>
                        <a class="waves-effect"
                           href="javascript:<c:if test="${fn:length(upmsPermission.uri)>0}">Tab.addTab('${upmsPermission.name}','${systemBasePath}${upmsPermission.uri}');</c:if>"><i
                                class="${upmsPermission.icon}"></i> ${upmsPermission.name}</a>
                        <ul>
                            <c:forEach var="subUpmsPermission" items="${upmsPermissions}">
                                <c:if test="${subUpmsPermission.pid == upmsPermission.permissionId  && subUpmsPermission.type == 2}">
                                    <li>
                                        <a class="waves-effect"
                                           href="javascript:Tab.addTab('${subUpmsPermission.name}', '${systemBasePath}${subUpmsPermission.uri}');">${subUpmsPermission.name}</a>
                                    </li>
                                </c:if>
                            </c:forEach>
                        </ul>
                    </li>
                </c:if>
            </c:forEach>
            <li>
                <div class="upms-version">&copy; JSINFO-UPMS V1.0.0</div>
            </li>
        </ul>
        <!-- /菜单区 -->
    </aside>
    <!-- /左侧导航区 -->
    <section id="content">
        <div class="content_tab">
            <div class="tab_left">
                <a class="waves-effect waves-light" href="javascript:;"><i class="zmdi zmdi-chevron-left"></i></a>
            </div>
            <div class="tab_right">
                <a class="waves-effect waves-light" href="javascript:;"><i class="zmdi zmdi-chevron-right"></i></a>
            </div>
            <ul id="tabs" class="tabs">
                <li id="tab_home" data-index="home" data-closeable="false" class="cur">
                    <a class="waves-effect waves-light" href="javascript:;">首页</a>
                </li>
            </ul>
        </div>
        <div class="content_main">
            <div id="iframe_home" class="iframe cur">
                <p><h4>河南省江山信息产业有限公司办公系统</h4></p>
            </div>
        </div>
    </section>

</section>
<footer id="footer"></footer>
<script>var BASE_PATH = '${basePath}';</script>
<script src="${basePath}/resources/zheng-admin/plugins/jquery.1.12.4.min.js"></script>
<script src="${basePath}/resources/zheng-admin/plugins/bootstrap-3.3.0/js/bootstrap.min.js"></script>
<script src="${basePath}/resources/zheng-admin/plugins/waves-0.7.5/waves.min.js"></script>
<script src="${basePath}/resources/zheng-admin/plugins/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.concat.min.js"></script>
<script src="${basePath}/resources/zheng-admin/plugins/BootstrapMenu.min.js"></script>
<script src="${basePath}/resources/zheng-admin/plugins/device.min.js"></script>
<script src="${basePath}/resources/zheng-admin/plugins/jquery.cookie.js"></script>
<script src="${basePath}/resources/zheng-admin/plugins/fullPage/jquery.fullPage.min.js"></script>
<script src="${basePath}/resources/zheng-admin/plugins/fullPage/jquery.jdirk.min.js"></script>
<script type="text/javascript">
    var menuItem = [];
    //页面加载完成
    $(document).ready(function () {
        <c:forEach var="upmsSystem" items="${upmsSystems}" varStatus="status">
            pushMenuItem("${upmsSystem.title}", "${upmsSystem.systemId}", "${upmsSystem.name}", "${upmsSystem.icon}");
        </c:forEach>
        var inMenuItem;
        for ( var i = 0; i <menuItem.length; i++){
            if($.cookie('zheng-upms-systemid') in menuItem[i]){
                inMenuItem = true;
                break;
            }
        }
        if(typeof ($.cookie('zheng-upms-systemid')) == "undefined" || typeof ($.cookie('zheng-upms-systemname')) == "undefined"
                || typeof ($.cookie('zheng-upms-systemtitle')) == "undefined" || !inMenuItem){
            $.cookie('zheng-upms-systemid', menuItem[0].systemid);
            $.cookie('zheng-upms-systemname', menuItem[0].systemname);
            $.cookie('zheng-upms-systemtitle', menuItem[0].systemtitle);
        }


        resizeMenu();
    });
    //窗口变化
    $(window).resize(function () {
        resizeMenu();
    });

    function resizeMenu() {
        var realItem = 0;
        var menuWidth = document.body.clientWidth * 0.5 - 60;
        var itemMax = (menuWidth - menuWidth % 130) / 130;
        realItem = itemMax > menuItem.length ? menuItem.length : itemMax;

        $("#nav-menu").empty();
        $("#more-menu").empty();
        for (var i = 0; i < realItem; i++) {
            $("#nav-menu").append('<li>' +
                    '<a class="waves-effect switch-systems" href="javascript:;" systemid="' + menuItem[i].systemid + '" systemname="' + menuItem[i].systemname + '" systemtitle="' + menuItem[i].systemtitle + '">' +
                    '<i class="' + menuItem[i].icon + '"></i>' +
                    menuItem[i].systemtitle + '</a>' +
                    '</li>');
        }
        if (menuItem.length > realItem) {
            $("#nav-menu").append('<ul class="hi-menu" style="float:left"><li class="dropdown"><a class="waves-effect waves-light" data-toggle="dropdown" href="javascript:;"><i class="him-icon zmdi zmdi-dropbox"></i></a><ul id="more-menu" class="dropdown-menu dm-icon pull-right"></ul></li></ul>');
            for (var i = realItem; i < menuItem.length; i++) {
                $("#more-menu").append('<li>' +
                        '<a class="waves-effect switch-systems" href="javascript:;" systemid="' + menuItem[i].systemid + '" systemname="' + menuItem[i].systemname + '" systemtitle="' + menuItem[i].systemtitle + '">' +
                        '<i class="zmdi zmdi-shield-security"></i>' +
                        menuItem[i].systemtitle + '</a>' +
                        '</li>');
            }
        }
    }

    function pushMenuItem(systemtitle, systemid, systemname, icon) {
        var upmsSystem = {};
        upmsSystem.systemtitle = systemtitle;
        upmsSystem.systemid = systemid;
        upmsSystem.systemname = systemname;
        upmsSystem.icon = icon;
        menuItem.push(upmsSystem);
    }
</script>
<script src="${basePath}/resources/zheng-admin/js/admin.js"></script>
</body>
</html>